<?php

namespace app\api\model\employ;

use app\common\model\employ\Poster as PosterModel;
use think\facade\Cache;

class Poster extends PosterModel
{
    public function getPublish($user)
    {
        $shop_supplier_id = Cache::get($user['user_id'] . '_shop_supplier_id');
        $publish = $this->with(["qr_code", "bg_image"])
            ->where(["shop_supplier_id" => $shop_supplier_id, "is_delete" => 0, "is_audit" => 1, "publish_status" => 1])
            ->order("update_time", "desc")->find();
        if ($publish) return $publish;
        $cityInfo = Cache::get($user['user_id'] . '_mycity_numid');

        if (empty($cityInfo)) {
            return false;
        }
        $province_id = $cityInfo[0];
        $city_id = $cityInfo[1];
        return $this->with(["qr_code", "bg_image"])->where(["province_id" => $province_id, "city_id" => $city_id, "is_delete" => 0, "is_audit" => 1, "publish_status" => 1])->order("update_time", "desc")->find();

    }
}